/*
 * @Description:游戏实例
 * @Author: maskMan
 * @LastEditTime: 2024-10-17 18:23:29
 */
import cacheStore from '../general/cacheStore'
import Hall from './hall'
export default class GameInstance extends cc.Component {
  //当前用户
  user: IUserInfo
  /**本次游戏数据 */
  gameData: IGameData
  /**开始时间 */
  startTime: number
  endTime: number
  currGame: string
  /**创建用户游戏记录 */
  public createUserScore(userScore: IUserScore): boolean {
    try {
      const result = Hall.instance.trainRecord.find((v) => v.startTime != userScore.startTime)
      if (!result) {
        Hall.instance.trainRecord.push(userScore)
        cacheStore.setUserRecord(userScore.uid, userScore)
      }
      return true
    } catch (error) {
      console.log('error: ', error)
      return false
    }
  }
}
